package com.qf.cx.simplenms.readergroup.model;

import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArraySet;

import com.qf.cx.simplenms.reader.model.AntennaModel;

public class ReaderGroupModel {
	private String name;
	private Set<AntennaModel> antennas = new CopyOnWriteArraySet<>();

	public synchronized String getName() {
		return name;
	}

	public synchronized void setName(String name) {
		this.name = name;
	}

	public synchronized Set<AntennaModel> getAntennas() {
		return new HashSet<>(antennas);
	}

	public synchronized void setAntennas(Set<AntennaModel> antennas) {
		this.antennas = antennas;
	}

	public synchronized void deleteAntennas(Set<AntennaModel> antennas) {
		this.antennas.removeAll(antennas);
	}

	public synchronized void addAntennas(Set<AntennaModel> antennas) {
		this.antennas.addAll(antennas);
	}

	public synchronized boolean contains(AntennaModel antenna) {
		return this.antennas.contains(antenna);
	}

	public synchronized boolean containsReader(String readerName) {
		for (AntennaModel antennaModel : antennas) {
			if (antennaModel.getReaderName().equals(readerName)) {
				return true;
			}
		}
		return false;
	}

	@Override
	public String toString() {
		return "ReaderGroupModel [name=" + name + ", antennas=" + antennas + "]";
	}

}
